<template>
	<view>
		<TopNavCustom :title="zone"></TopNavCustom>
		<view class="container">
			<image :src="getSrc(_item.attributeMap)" class="image"></image>
			<view v-if="nodeList.length != 0">
				<view class="card" v-for="(node, index) in nodeList" :key="index">
					<u-cell-group>
						<u-cell size="large" :iconStyle="iconStyle" :title="node.partName" :icon="node._src"
							@click="goto(node)" isLink>
						</u-cell>
					</u-cell-group>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import _utils from "@/common/_utils.js";
	import $C from '@/common/config.js'
	import _constant from "@/common/constant.js"
	import _public from '@/common/public.js'
	
	export default {
		created() {
			this.getSelectNode();
		},
		data() {
			return {
				zone: "A栋 B单元 7楼309",
				iconStyle: {
					width: "40rpx",
					height: "40rpx",
				},
				nodeList: [],
			};
		},
		onLoad(item) {
			this._item = JSON.parse(decodeURIComponent(item.item));
			console.log(item);
			this.zone = this._item.building + "栋" + this._item.unit + "单元" + this._item.num + "号";
		},
		methods: {
			getSrc(src) {
				console.log(src)
				if (src == null || (typeof src.plan) == undefined || src.plan == null || src.plan == '') {
					return null
				}else{
					let _src = $C.baseUrl + '/file/download?fileId=' + src.plan
					return _src
				}
			},
			//获取 estateId 对应绑定的node
			async getSelectNode() {
				let id = await _constant.getConstentPartId('房屋芯造')
				const data = await _public.getSelecHouseNode(id)
				if (data.length != 0) {
					this.nodeList = _utils.backHouseNodeArray(data);
				}
			},
			goto(node) {
				let _node = node;
				_node.estateId = uni.getStorageSync('houseId');
				_node.flag = false;
				let item = encodeURIComponent(JSON.stringify(_node));
				uni.navigateTo({
					url: "/pages/ihome/public_building_PM/public_building_PM?item=" + item,
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.container {
		padding: 20rpx 30rpx 0 30rpx;

		.image {
			border: 1rpx solid #efefef;
			width: 690rpx;
			height: 320rpx;
			margin-bottom: 20rpx;
		}

		.card {
			border: 1rpx solid #efefef;
			background: #ffffff;
			border-radius: 20rpx;
		}
	}
</style>
